﻿#ifndef __lvgl_Project_H__
#define __lvgl_Project_H__


#ifdef __cplusplus
extern "C" {
#endif


#include "main.h"
#include "stdbool.h"

#include "lvgl.h"
#include "string.h"
#include "stdio.h"
#include "font.h"
#include "math.h"
#include "my_system.h"


typedef struct
{

    lv_task_t* task;
    bool flag;
    uint32_t count;
    uint8_t num;

}__lvgl_close_data;

#include "lv_gif.h"
#include "lvgl_image.h"
#include "lvgl_style.h"
#include "lvgl_desktop.h"
#include "lvgl_power_on.h"
#include "lvgl_clock.h"
#include "lvgl_radio.h"
#include "lvgl_bilibili.h"
#include "lvgl_refresh.h"
#include "lvgl_laohuangli.h"
#include "lvgl_hint.h"
#include "lvgl_clock_style2.h"
#include "lvgl_radio.h"
#include "lvgl_power_off.h"
#include "lvgl_backlight.h"
#include "lvgl_temp.h"

#if 1
#define lvgl_project_debug( tag, format, ... ) \
printf("%s",tag); \
printf(format,##__VA_ARGS__);\
printf("\r\n");
#else
#define project_debug( tag, format, ... ) ;
#endif

#if 1
#define project_debug(format, ...) lvgl_project_debug("[lvgl project_debug]- ",format,##__VA_ARGS__);
#else
#define project_debug_debug(format, ...) ;
#endif


//lv_anim_path_linear线性动画
//lv_anim_path_step最后一步更改
//lv_anim_path_ease_in开头很慢
//lv_anim_path_ease_out最后慢
//lv_anim_path_ease_in_out在开始和结束时也很慢
//lv_anim_path_overshoot超出最终值
//lv_anim_path_bounce从最终值反弹一点（就像撞墙一样）
#define LVGL_ANIM_IN_TIME   300
#define LVGL_ANIM_OUT_TIME  200
#define LVGL_ANIM_IN_PATH   lv_anim_path_ease_out
#define LVGL_ANIM_OUT_PATH  lv_anim_path_ease_in

#define LVGL_ANIM_SWITCH 1

#if 1//USE_WIN == 1
typedef enum {
    BSP_POWER_ON_TYPE_USB=0,
    BSP_POWER_ON_TYPE_KEY,

}BSP_POWER_ON_TYPE;
#endif


#define LVGL_MALLOC         lv_mem_alloc
#define LVGL_FREE(x)        if(x)lv_mem_free

extern  lv_indev_t *g_indev_keypad;

typedef enum {
    CZ_EVENT_REFRESH_READY = 100,
    CZ_EVENT_ANIM_IN_READY,
    CZ_EVENT_ANIM_OUT_READY,
    CZ_EVENT_ENTER_LEFT,
    CZ_EVENT_ENTER_RIGHT,

    CZ_EVENT_REFRESH_OVER,

}LVGL_CZ_EVENT;


typedef enum {
	type_btn = 0,
	type_lable,
	type_sw,
}lvgl_obj_type;

typedef struct
{
    lv_coord_t x;
    lv_coord_t y;
    lv_coord_t w;
    lv_coord_t h;
}__lvgl_coord;


typedef struct
{
	lv_group_t * main_group;
	lv_obj_t ** save_focus_obj;
}__lvgl_project_data;

extern __lvgl_project_data lvgl_project_data;

extern const char *lvgl_globa_text[][10];


void lcgl_projet_init(void);
void lvgl_group_add_obj(lv_obj_t** obj);
void lvgl_group_remove_obj(lv_obj_t** obj);
void lvgl_group_focus_obj(lv_obj_t** obj);
lv_obj_t* lvgl_group_get_focus_obj(void);
void lvgl_group_save_focus_obj(void);
void lvgl_group_focus_save_obj(void);
uint8_t lvgl_send_event(lv_obj_t** obj, lv_event_t event, void* dat);
uint8_t lvgl_send_event_to_focus(lv_event_t event, void* dat);

void lvgl_set_obj_hide(lv_obj_t ** obj);
void lvgl_set_obj_show(lv_obj_t ** obj);
uint8_t lvgl_task_create(lv_task_t **handel,lv_task_cb_t task_cb, uint32_t period, lv_task_prio_t prio, void * user_data);
void lvgl_task_delete(lv_task_t ** task);
void lvgl_obj_clean(lv_obj_t **obj);
void lvgl_obj_del(lv_obj_t **obj);



#ifdef __cplusplus
}
#endif
#endif
